package com.example.demo.TakeMaterial.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.TakeMaterial.entity.DeliveryForm;
import com.example.demo.TakeMaterial.mapper.DeliveryFormMapper;
import com.example.demo.TakeMaterial.service.DeliveryFormService;
import com.example.demo.common.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 服务实现类
 */
@Service
public class DeliveryFormServiceImpl extends ServiceImpl<DeliveryFormMapper,DeliveryForm> implements DeliveryFormService {

    @Autowired
    private DeliveryFormMapper deliveryFormMapper;
    @Override
    public ResponseData selectAll() {
        List<DeliveryForm> deliveryFormList=new ArrayList<>();
        deliveryFormList=deliveryFormMapper.selectList(null);
        return ResponseData.buildOk(deliveryFormList);
    }

    @Override
    public ResponseData selectBetweenDate(String beginDate, String endDate) {
        List<DeliveryForm> deliveryFormList=new ArrayList<>();
        QueryWrapper<DeliveryForm> wrapper =new QueryWrapper<>();
        wrapper.between("out_date",beginDate,endDate);
        deliveryFormList=deliveryFormMapper.selectList(wrapper);
        return ResponseData.buildOk(deliveryFormList);
        }

    @Override
    public ResponseData selectRequisitionId(String requisitionId) {
        List<DeliveryForm> deliveryFormList=new ArrayList<>();
        QueryWrapper<DeliveryForm> wrapper=new QueryWrapper<>();
        wrapper.like("requisition_id",requisitionId);
        deliveryFormList=deliveryFormMapper.selectList(wrapper);
        return ResponseData.buildOk(deliveryFormList);
    }
}
